package com.onepower.admin.controller;


import com.onepower.core.domain.response.MatchScoreInfo;
import com.onepower.core.modules.repository.entity.MatchScore;
import com.onepower.core.modules.service.IMatchScoreService;
import com.onepower.core.result.CommonResult;
import com.onepower.core.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * <p>
 * 比赛分数表 前端控制器
 * </p>
 *
 * @author kin
 * @since 2018-08-12
 */
@RestController
@RequestMapping("/api/match/score")
public class MatchScoreController {

    @Autowired
    private IMatchScoreService matchScoreService;

    @RequestMapping(value = "/info")
    public CommonResult getMatchScore(@RequestParam int matchId,
                                      @RequestParam int matchAdminId) {
        MatchScoreInfo scoreInfo = matchScoreService.getMatchScore(matchId, matchAdminId);
        return ResultUtils.ok(scoreInfo);
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public CommonResult save(@RequestBody MatchScore matchScore) {
        matchScoreService.save(matchScore);
        return new CommonResult();
    }

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public CommonResult delete(@RequestBody Integer[] scoreIds) {
        matchScoreService.removeByIds(Arrays.asList(scoreIds));
        return new CommonResult();
    }

}
